/* common.js
 * commonEvent: 公共事件类
 *     add    : 添加事件(元素对象，事件类型，回调函数，是否捕获)
 *     remove : 删除事件(同上)
 * 
 * by cuiab
 * date 2017/01/06
 * update1    : edit add
 * update2    : edit remove
 */

var commonEvent = {
    add: function (element, type, callback, isBuhuo){
        if(element.addEventListener){
            element.addEventListener(type, callback, isBuhuo || false);
        }else if(element.attachEvent){
            element.attachEvent("on" + type, callback);
        }else{
            element["on" + type] = callback;
        }
    },
    remove: function (element, type, callback, isBuhuo){
        if(element.removeEventListener){
            element.removeEventListener(type, callback, isBuhuo || false);
        }else if(element.detachEvent){
            element.detachEvent("on" + type, callback);
        }else{
            element["on" + type] = null;
        }
    },
    stopPropagation:function(e){
    	if(e.stopPropagation ){
    		
    	}else{
    		e.cancelBubble=true;
    	}
    },
    preventDefault:function(e){
    	if(e.preventDefault){
    		
    	}else{
    		e.returnValue=true;
    	}
    },
    getEvent:function(e){
    	return e || window.event;
    	
    },
    getTarget:function(e){
    	if(e.target){
    		return e.target
    	}else{
    		return e.srcElement;
    	}
    },
    
    tab:function (tag,tagDiv,type,show,active){
		for(var i=0, len=tag.length; i<len; i++){
		tag[i].index=i;
		tag[i][type]=function(){
			for( var i=0; i<len; i++){
				tagDiv[i].className="";
				tag[i].className="";
			}
			tagDiv[this.index].className=show;
			this.className=active;
			}
		}
				 
	},
    
    paseQueryString:function(){
    	
    	
    	
    }
    
    
    
    
   
    
}

//function，定义一个可重复调用的具有特定功能的代码块
